<template>
  <div class="layout-container full">
    <!-- 执行面板 -->
    <div v-show="!logVisible" class="panel-wrapper">
      <exec-panel @submit="openLog" />
    </div>
    <!-- 执行日志 -->
    <div v-if="logVisible" class="panel-wrapper">
      <exec-log-panel ref="log"
                      :visibleBack="true"
                      @back="setLogVisible(false)" />
    </div>
  </div>
</template>

<script lang="ts">
  export default {
    name: 'execCommand'
  };
</script>

<script lang="ts" setup>
  import type { ExecLogQueryResponse } from '@/api/exec/exec-log';
  import { nextTick, onMounted, ref } from 'vue';
  import useVisible from '@/hooks/visible';
  import { useDictStore } from '@/store';
  import { dictKeys } from '@/views/exec/exec-log/types/const';
  import ExecPanel from './components/exec-panel.vue';
  import ExecLogPanel from '@/components/exec/log/panel/index.vue';

  const { visible: logVisible, setVisible: setLogVisible } = useVisible();

  const log = ref();

  // 打开日志
  const openLog = (record: ExecLogQueryResponse) => {
    setLogVisible(true);
    nextTick(() => {
      log.value.open(record);
    });
  };

  // 加载字典值
  onMounted(async () => {
    const dictStore = useDictStore();
    await dictStore.loadKeys(dictKeys);
  });

</script>

<style lang="less" scoped>

  .panel-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
  }

</style>
